<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>请你免费去韩国</title>
		<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0'/>
		<link rel="stylesheet" href="{$_C.hy_path}css/run/public.css" />
		<link rel="stylesheet" href="{$_C.hy_path}css/run/xinxi.css" />
	</head>
	<body>
		<div class="shen"><img src="{$_C.hy_path}images/run/shen.png"></div>
		<div class="shubox">
			<div class="mingc">
				<span>姓名</span>
				<input type="text" id="name" placeholder="" />
			</div>
		</div>
		<div class="shubox">
			<div class="mingc">
				<span>年龄</span>
				<input type="int" id="age" placeholder="" />
			</div>
		</div>
		<div class="shubox">
			<div class="mingc">
				<span>所属跑团(选填)</span>
				<input type="text" id="run_group" placeholder="" />
			</div>
		</div>
		<div class="shubox">
			<div class="mingc">
				<span>联系电话</span>
				<input type="text" id="telphone" placeholder="" />
			</div>
		</div>
		<div class="xiu"><span>秀一下你的跑姿</span></div>
		<div class="xianji"><img src="{$_C.hy_path}images/run/icon.png"></div>
		<div class="xiu"><span>我的理由</span></div>
		<div class="liyou">
			<textarea id="reason" placeholder="想免费跑！输入你的跑步故事吧～ （120字以内）"></textarea>
		</div>
		<div class="bn"><a onClick="apply();" ><img src="{$_C.hy_path}images/run/icontij.png"></a></div>
		<div class="canx">
			<img src="{$_C.hy_path}images/run/canx.jpg">
			<div id="dianj" onclick="return ongx()"></div>
		</div>
		<script type="text/javascript" src="{$_C.hy_path}js/jquery-1.10.2.min.js" ></script>
		<script type="text/javascript" src="{$_C.hy_path}js/run/public.js" ></script>
		<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
		
		
<script>
		  wx.config({
		    debug: false, 
		   appId: '{$jsdk.appId}',
				timestamp: {$jsdk.timestamp},
				nonceStr: '{$jsdk.nonceStr}',
				signature: '{$jsdk.signature}',
		    jsApiList: [
		      // 所有要调用的 API 都要加到这个列表中
			  'chooseImage',
				'previewImage',
				'uploadImage',
				'downloadImage',
		      'onMenuShareTimeline',
		      'onMenuShareAppMessage',
		    
		    ]
		  });
		
		  wx.ready(function () {
 			wx.onMenuShareTimeline({
			    title: '用你的跑故事换一次免费韩国樱花跑之旅',
			     link:'http://g4.shfyuan.com/xy/index.php?g=mobile&m=run&a=index',
			     imgUrl: 'http://g4.shfyuan.com/xy/Mobile/Webroot/gf/images/run/share-info.png',
			      trigger: function (res) {
			       
			      },
			      success: function (res) {
			    	 
			      },
			      cancel: function (res) {
			       
			      },
			      fail: function (res) {
			      }
		    });
		    
			wx.onMenuShareAppMessage({
			    link:'http://g4.shfyuan.com/xy/index.php?g=mobile&m=run&a=index',
			     title: '福利福利',
			    desc: '敢用你的跑故事，换一次免费韩国樱花跑之旅吗?',
			  	imgUrl: 'http://g4.shfyuan.com/xy/Mobile/Webroot/gf/images/run/share-info.png',
			    success: function () { 
			    	
			    },
			    cancel: function () { 
			        // 用户取消分享后执行的回调函数
			    }
		});

  });
			
			var localId,urls = {
				   current: '', // 当前显示图片的http链接
    				urls: [] // 需要预览的图片http链接列表
				  };
				$('.xianji').click(function(){
					wx.chooseImage({
						count: 1,
						success: function (res) {
							console.info(res);
					        if (res.localIds.length == 0) {
					  	      	warn('请先选择图片');
								return;
					  	    }
					        localId = res.localIds[0];
					        function upload() 
					        {
								var img;
					        	wx.uploadImage({
					        		localId: localId,
					      		    success: function (res) {
					      		    	img = res.serverId;
					      		    	$.post('index.php?g=mobile&m=run&a=upload_img',{ img:img },function(result){
					      		    		if(result.error == 0)
					      		    		{
												$(".xianji").html(result.url);
//												alert(result.content);
												$(".mingc").eq(0).append(result.content);
				      		    				warn("上传成功");
//												urls.current = result.img;
//												$(".pre-img").click(function(){
//													wx.previewImage(urls);
//												})
					      		    		}
					      		    		else
					      		    		{
					      		    			warn('上传失败');
					      		    			return;
					      		    		}
					      		    	},'json');
					      		    }
					        	});
					        }
					        upload();
					    }
				});
			});
			
		</script>
	</body>
</html>
